//
//  LoginViewController.m
//  SaveHearts
//
//  Created by Daehee Han on 6/26/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "LoginViewController.h"

@implementation LoginViewController

@synthesize emailText;
@synthesize passwordText;
@synthesize cancelButton;
@synthesize enterButton;
@synthesize forgetPwButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [emailText becomeFirstResponder];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

// User Interface actions
- (IBAction)docancelButton:(id) sender
{
    // --- remove the current view; essentially hiding the view ---
    [self.navigationController popViewControllerAnimated:YES];
 // [self.view removeFromSuperview];

}

- (IBAction)doenterButton:(id) sender
{
    NSString *emptyStr;
    UIAlertView *alert;
    if (emailText.text.length < 1 ) {
        emptyStr = [[NSString alloc] initWithFormat:@"Warning!"];
        
        alert = [[UIAlertView alloc]
                              initWithTitle:emptyStr
                              message:@"Please check your email."
                              delegate:self
                              cancelButtonTitle:@"Done"
                              otherButtonTitles:nil];
        [alert show];
    } else if (passwordText.text.length < 1) {
        emptyStr = [[NSString alloc] initWithFormat:@"Warning!"];
        
        alert = [[UIAlertView alloc]
                              initWithTitle:emptyStr
                              message:@"Please check your password."
                              delegate:self
                              cancelButtonTitle:@"Done"
                              otherButtonTitles:nil];
        [alert show];
    }
    else {
        NSString *str = [[NSString alloc] initWithFormat:@"Send, %@", emailText.text];
        
        alert = [[UIAlertView alloc]
                              initWithTitle:@"SendButton Clicked"
                              message:str
                              delegate:self
                              cancelButtonTitle:@"Done"
                              otherButtonTitles:nil];
        [alert show];
        
    }

}

@end
